package mediafile

import (
	"net/http"

	"mall/common/resultx"
	"mall/service/forum/api/internal/handler/util"
	"mall/service/forum/api/internal/logic/mediafile"
	"mall/service/forum/api/internal/svc"
	"mall/service/forum/api/internal/types"
)

func UploadHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		l := mediafile.NewUploadLogic(r, svcCtx)
		var headers []*types.Header
		resp, err := l.Upload(&headers)
		w = util.SetHeaders(w, headers)
		resultx.HttpResult(r, w, resp, err)
	}
}
